home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-04-16 | 3.1 KB | 114 lines | [TEXT/CWIE] |
- //----------------------------------------------------------------
- // IARouter
- // Copyright: © 1997 - 1998 by Apple Computer, Inc., all rights reserved.
- //
- // Identifies the cluster of documents that a document belongs to
- //
- //----------------------------------------------------------------
- #pragma once
- #ifndef IARouter_h
- #define IARouter_h
-
- #pragma import on
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=power
- #endif
-
- #include <time.h>
- class IAStorage;
- class IAStoreStream;
- class TWVector;
- class VectorIndex;
- class IADocIterator;
- class IADoc;
- class IACorpus;
- class IACluster;
- class IAIndex;
- class VectorAccessor;
-
- #include "IACommon.h"
- #include "IAStorage.h"
-
- #pragma IA_BEGIN_EXPORTS
-
- class IARouter : public IAObject {
- public:
- IARouter(VectorIndex* index, TProgressFn* progress = NULL, clock_t progressFreq = 0xFFFFFFFFul, void* appData = NULL);
-
- virtual ~IARouter();
-
- // clusters is an array of IACluster pointers.
- void InitializeClusters(IACluster** clusters, uint32 howManyClusters);
- // given a document, which cluster group is the best to add this document to
- uint32 WhichCluster (IADoc* doc, bool accumulate = false);
- // save the state of the router and the normalized cluster vectors
- void Store (IAStorage* storage = NULL, IABlockID block = 0) const;
- // restore the state of the router and the normalized cluster vectors from storage
- // if you restore then no need to call InitializeClusters
- void Restore (IAStorage* storage = NULL, IABlockID block = 0);
- // store size of this router
- IABlockSize StoreSize() const;
-
-
- TProgressFn* GetProgressFn() const {return fProgressFn;}
- void* GetProgressData() const {return fProgressData;}
- clock_t GetProgressFreq() const {return fProgressFreq;}
-
- protected:
- // return the best matching cluster for the given vector.
- uint32 BestCluster(TWVector *vector ) const;
- // accumulator
- void ClearAccumulator( void );
- void AddDocVectorToAccumulator(TWVector* newDocVector);
- void AccumulateDocVector(IADoc* doc);
- void AddToAccumulator (uint32 cluster, TWVector *docVector);
-
- private:
-
- TWVector* fVectorAccumulator;
- uint32 fClusterCount; // how many clusters there are
- TWVector** fClusterVectors; // vector for centroid of each cluster
- VectorIndex* fIndex; // our index
- TProgressFn* fProgressFn; // for showing how we're doing
- // may be NULL.
- void* fProgressData;
- clock_t fProgressFreq;
-
- VectorAccessor* fAccessor;
- };
-
-
-
- class IACluster : public IAObject {
- public:
- IACluster (IAIndex* index);
- virtual ~IACluster();
- virtual IADoc* GetNextDoc() const = 0; // return the next document
- // in the cluster
- // this is platform specific
- // for example HFSCluster will return
- // documents of type HFSDoc
-
- virtual void Reset() = 0; // resets the iterator for another round of
- // iteration
- protected:
- IACorpus* GetCorpus() const {return fCorpus;}
- private:
- IACorpus* fCorpus;
- };
-
-
- IAExceptionCode IARouterAlreadyInitialized = 'VRAI';
- IAExceptionCode IARouterNotInitialized = 'VRNI';
-
- #pragma IA_END_EXPORTS
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #endif
-
- #pragma import reset
-
-
- #endif
-